package no.ntnu.item.ttm4115.termproject.discussionagent.gui;

import java.util.Vector;

import no.ntnu.item.ttm4115.termproject.extrasagent.Player;


/**
 * This class defined the structure (attributes) of the discussion object
 * This discussion object will be the discussion tree node
 * @author surya
 *
 */
public class Discussion {
	
	private String topicText;
	private int topicId;
	private String postedDate;
	private String postedLocation;
	private Player postedBy;
	
	private Discussion parent;
	private Vector<Discussion>childrens;
	
	/**
	 * Default Collection
	 */ 
	private Vector<Discussion> defaultDiscussions; 
	
	/**
	 * Create constructor from using fields
	 */ 
	public Discussion(String topicText, int topicId, String postedDate, String postedLocation,
			Player postedBy) {
		this.topicText = topicText;
		this.topicId = topicId;
		this.postedDate = postedDate;
		this.postedLocation = postedLocation;
		this.postedBy = postedBy;
		
		parent = null;
		childrens = new Vector<Discussion>();
	}
	
	public Discussion(String topicText)
	{
		this.topicText = topicText;
	}
	
	public Discussion(String topicText,String postedDate, Player postedBy)
	{
		this.topicText = topicText;
		this.postedBy = postedBy;
		this.postedDate = postedDate;
	}

	
	/**
	 *  constructor for populating the default discussions
	 */
	public Discussion(){
		
		this.defaultDiscussions = new Vector<Discussion>();
		this.defaultDiscussions.add(new Discussion("Discussion 1"));
		this.defaultDiscussions.add( new Discussion("Discussion 2"));
		this.defaultDiscussions.add(  new Discussion("Discussion 3"));	
	}
	
	/**
	 * Getter and Setter Methods
	 */
	public String getTopicText() {
		return topicText;
	}
	public void setTopicText(String topicText) {
		this.topicText = topicText;
	}
	public int getTopicId() {
		return topicId;
	}
	public void setTopicId(int topicId) {
		this.topicId = topicId;
	}
	public String getPostedDate() {
		return postedDate;
	}
	public void setPostedDate(String postedDate) {
		this.postedDate = postedDate;
	}	
	public String getPostedLocation() {
		return postedLocation;
	}
	public void setPostedLocation(String postedLocation) {
		this.postedLocation = postedLocation;
	}
	public Player getPostedBy(){
		return postedBy;
	}
	public void setPostedBy(Player player){
		this.postedBy = player;
	}
	/**
	 * Other methods for the childrens of the tree node
	 */ 
    public Discussion getChildAt(int i) {
        return (Discussion)childrens.elementAt(i);
    }
    public int getIndexOfChild(Discussion kid) {
        return childrens.indexOf(kid);
    }
    public int getChildCount() { return childrens.size();}

	public Discussion getParent() {
		return parent;
	}

	// Gettter and setters
	public void setParent(Discussion parent) {
		this.parent = parent;
	}

	public Vector<Discussion> getChildrens() {
		return childrens;
	}

	public void setChildrens(Vector<Discussion> childrens) {
		this.childrens = childrens;
	}

	// To customize the display in JTree nodes
	public String toString() {
		return (getTopicText());
	}

	public Vector<Discussion> getDefaultDiscussions() {
		return defaultDiscussions;
	}

	public void setDefaultDiscussions(Vector<Discussion> defaultDiscussions) {
		this.defaultDiscussions = defaultDiscussions;
	} 
	
	
}
